package allod.som.input

import allod.som.Lattice.Pattern

/**
 * Created by IntelliJ IDEA.
 * User: allod
 * Date: 7 квіт 2010
 * Time: 20:56:46
 */

abstract class InputSource {
  val inputDimension: Int

  val elements: Seq[Pattern]

  val labels: Seq[String]

  def elementsCount: Int = elements.size

  def randomElement = {
    val index: Int = (Math.random * elementsCount).asInstanceOf[Int]
    elements(index)
  }

  def labelForPattern(pattern: Pattern) = {
    val position = elements.findIndexOf(_ == pattern)
    if (position < 0) {
      throw new Exception("No such element exception")
    }
    labels(position)
  }
}